<html>
	<head>
		<meta charset="utf-8" />
        <style type=text/css>
        body{
            background-image:url(bj.jpg);
            
            }
              div {
            width:350px;
            height:250px;
            border:1px solid #ffc0cb;
            box-sizing: border-box;
            line-height:35px;
            padding-top:1px;
            margin-top:15%;
            margin-left:40%;
            text-align:center;
        }
       .tj{
        margin-left:1px; 
        margin-right:100px;
       }
        </style>
	</head>
	<body>
        <div>
        <h2>欢迎注册</h2>
       <form method="post" action="">
           用&nbsp;&nbsp;户&nbsp;&nbsp;名：<input rype='text' name="username"><br>
           密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：<input rype='password' name="pwd"><br>
           确认密码：<input rype='password' name="qrpwd"><p>
           <input type="submit" value="提交" class="tj">
           <input type="button" onclick="window.location.href='index.php'" value="取消">

        </form>
        </div>
	</body>
</html>
<?php
require 'conn.php';
if(isset($_POST['username']) && isset($_POST['pwd']) && isset($_POST['qrpwd']) && $_POST['pwd']===$_POST['qrpwd'])
{
$username=$_POST['username'];
$pwd=$_POST['pwd'];
$result=mysqli_query($link,"insert into user(name,pwd) values ('$username','$pwd')");
if($result){
    echo "<script>alert('用户添加成功！');window.location.href='index.php';</script>";
}
else{
    echo "<script>alert('用户添加失败！');</script>";
}
}
else{
    echo "<script>alert('两次密码不一致！');</script>";
}

?>